using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

using BusinessObjects.BusinessRules;

namespace BusinessObjects
{
    /// <summary>
    /// Class that holds information about a customer.
    /// </summary>
    /// <remarks>
    /// Enterprise Design Pattern: Domain Model, Identity Field.
    /// 
    /// This is also the place where business rules are established.
    /// 
    /// The Domain Model Design Pattern states that domain objects incorporate 
    /// both behavior and data. Behavior may include simple or complex business logic.
    /// 
    /// The Identity Field Design Pattern saves the ID field in an object to maintain
    /// identity between an in-memory business object and that database rows.
    /// </remarks>
    public class Customer : BusinessObject
    {
        /// <summary>
        /// Default constructor for customer class.
        /// Initializes automatic properties.
        /// </summary>
        public Customer()
        {
            // Default property values
           
            // Business rules
            AddRule(new ValidateId("CustomerId"));

            AddRule(new ValidateRequired("CompanyName"));
            AddRule(new ValidateLength("CompanyName", 1, 100));

            AddRule(new ValidateRequired("Name"));
            AddRule(new ValidateLength("Name", 1, 50));

            //AddRule(new ValidateRequired("City"));
            //AddRule(new ValidateLength("City", 1, 15));

            //AddRule(new ValidateRequired("Country"));
            //AddRule(new ValidateLength("Country", 1, 15));

            Version = _versionDefault;
        }

        /// <summary>
        /// Overloaded constructor for the Customer class.
        /// </summary>
        /// <param name="customerId">Unique Identifier for the Customer.</param>
        /// <param name="company">Name of the Customer.</param>
        /// <param name="city">City where Customer is located.</param>
        /// <param name="country">Country where Customer is located.</param>
        /// vietnh old version
        //public Customer(int customerId, string company, string city, string country)
        //    : this()
        //{
        //    CustomerId = customerId;
        //    Company = company;
        //    City = city;
        //    Country = country;
        //}
        //End

        public Customer(int customerId, string companyName, string name, global::System.Int32 city, global::System.Int32 country, string userName, string password, string telephone, string mobilePhone, string yahooId, string skypeId, string googleId, string facebookId, string email,int status)
            : this()
        {
            CustomerId = customerId;
            CompanyName = companyName;
            Name = name;
            City = city;
            Country = country;
            UserName = userName;
            Password = password;
            Email = email;
            Telephone = telephone;
            MobilePhone = mobilePhone;
            YahooId = yahooId;
            SkypeId = skypeId;
            GoogleId = googleId;
            FacebookId = facebookId;
            Status = status;
        }

        /// <summary>
        /// Gets or sets unique customer identifier.
        /// The Identity Field Design Pattern. 
        /// </summary>
        public int CustomerId { get; set; }

        /// <summary>
        /// Gets or sets the customer name.
        /// </summary>
        public string CompanyName { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the customer city.
        /// </summary>
        public global::System.Int32 City { get; set; }

        /// <summary>
        /// Gets or sets the customer country.
        /// </summary>
        public global::System.Int32 Country { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string Password { get; set; }

        public string Email { get; set; }

        public string Telephone { get; set; }

        public string MobilePhone { get; set; }

        public string YahooId { get; set; }

        public string GoogleId { get; set; }

        public string SkypeId { get; set; }

        public string FacebookId { get; set; }

        /// <summary>
        /// Gets or sets a list of all orders placed by the customer.
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// Gets or sets the version number. Used for optimistic concurrency.
        /// </summary>
        public string Version { get; set; }
    }
}
